package leader.action;

import java.util.List;

import leader.service.DirectPaperService;
import leader.service.DirectPatentService;

import com.opensymphony.xwork2.ActionContext;

import teacher.bean.Paper;
import teacher.bean.Patent;
import teacher.bean.Teacher;

public class DirectPatentStateAction {
	private List<Patent> patent;
	private int currentpage;
	private int endpage;
	private int count;
	private int pagesize;
	private int flag;
	public List<Patent> getPatent() {
		return patent;
	}
	public void setPatent(List<Patent> patent) {
		this.patent = patent;
	}
	public int getCurrentpage() {
		return currentpage;
	}
	public void setCurrentpage(int currentpage) {
		this.currentpage = currentpage;
	}
	public int getEndpage() {
		return endpage;
	}
	public void setEndpage(int endpage) {
		this.endpage = endpage;
	}
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
	}
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	public int getFlag() {
		return flag;
	}
	public void setFlag(int flag) {
		this.flag = flag;
	}
	public String execute() {
		System.out.println("==============成果分页开始============");
		Teacher lea=(Teacher) ActionContext.getContext().getSession().get("leader");
		DirectPatentService pat = new DirectPatentService();
		Patent acheve = new Patent();
	   	acheve.setExamine(0);
			pagesize = 10;
			count = pat.getCountOfDirectPatentByState(lea, acheve);
	    	if(currentpage == 0) {
	    		currentpage = 1;
	    	}
	    	int add = 0;
	    	if(count%pagesize != 0) {
	    		add = 1;
	    	}
	    	endpage = count/pagesize + add;
	    	if(currentpage > endpage && endpage > 0) {
	    		currentpage = endpage;
	    	}
	    	ActionContext.getContext().put("flag",3);
	    	flag = 3;
	    	patent = pat.selectSegregateDirectPatentByState(lea, acheve, (currentpage-1)*pagesize+1, pagesize);
	    	return "success";
	}
}
